home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group02b.txt / 000088_icon-group-sender_Thu Oct 24 12:29:15 2002.msg < prev    next >
Internet Message Format  |  2003-01-02  |  4KB

  1. Return-Path: <icon-group-sender>
  2. Received: (from root@localhost)
  3.     by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id g9OJSmU00911
  4.     for icon-group-addresses; Thu, 24 Oct 2002 12:28:48 -0700 (MST)
  5. Message-Id: <200210241928.g9OJSmU00911@baskerville.CS.Arizona.EDU>
  6. Date: Thu, 24 Oct 2002 08:46:16 -0700
  7. From: Steve Wampler <swampler@noao.edu>
  8. X-Accept-Language: en
  9. To: Trinity Palakkad <tipl2@hotmail.com>,
  10.    icon-group <icon-group@cs.arizona.edu>
  11. Subject: Re: Doubts in programming
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13. Status: RO
  14.  
  15. Trinity Palakkad wrote:
  16. > Program 1
  17. > link wopen
  18. > procedure main()
  19. >         WOpen("size=300,400","pos=100,100")
  20. >         WAttrib("bg=blue","fg=white","canvas=hidden")
  21. >         WDone()
  22. > end
  23. > After executing the program,no other programs can be executed
  24. > due to some linking error.Even the same program cannot be run
  25. > for a second time.What change is to be made to the program?
  26.  
  27. What linking error?  I don't think that's what you're seeing.
  28.  
  29. I think you're seeing the fact that WDone says to wait for
  30. a 'Q' or 'q' to be typed into the window before processing and
  31. you can't do that because you've opened the window as 'hidden',
  32. so you can't see it to type the 'Q' or 'q'.  Try:
  33.  
  34. procedure main()
  35.     WOpen("size=300,400","pos=100,100")
  36.     WAttrib("bg=blue","fg=white","canvas=normal")
  37.     WDone()
  38. end
  39.  
  40. instead and then type Q or q inside the window.  Or consider
  41. using WClose() instead of WDone, depending on what you want to
  42. do...
  43.  
  44. > Program 2
  45. > link wopen
  46. > procedure main()
  47. >         WOpen("size=300,400","pos=100,100","label=W1")
  48. >         WAttrib("bg=blue","fg=white","canvas=normal")
  49. >         WWrite("The window is in the normal state")
  50. >         WOpen("size=300,400","pos=200,200","label=W2")
  51. >         WAttrib("bg=blue","fg=white","canvas=hidden")
  52. >         WDone()
  53. > end
  54. > The program does not produce the desired result.
  55. > W2 has to be closed.Instead,W1 is being closed.
  56. > What change is to be made to the program?
  57.  
  58. Well, it does do what you told it to do, so I guess that
  59. wasn't what you desired...
  60.  
  61. The first WOpen sets &window, which is then used by subsequent
  62. Wxxx() functions that don't specify a window.  So the 2nd
  63. WAttrib() call that sets the canvas to hidden is hiding the
  64. first window, not the second.
  65.  
  66. I've found it to be good practice to use explicit window
  67. names anytime I'm using more than one window.  Doing so,
  68. the above program would be (something like):
  69.  
  70. link wopen
  71.  
  72. procedure main()
  73.         w1 := WOpen("size=300,400","pos=100,100","label=W1")
  74.         WAttrib(w1,"bg=blue","fg=white","canvas=normal")
  75.         WWrite(w1,"The window is in the normal state")
  76.  
  77.         w2 := WOpen("size=300,400","pos=200,200","label=W2")
  78.         WAttrib(w2,"bg=blue","fg=white","canvas=hidden")
  79.         WClose(w2)
  80.  
  81.         WDone(w1)
  82. end
  83.  
  84. Note that I'm using WClose(w2) and not WDone(w2) - since you've
  85. got w2 'hidden', WDone(w2) would be a problem, just as it was
  86. with the hidden window in your first example.
  87.  
  88. If you don't have the "Graphics Programming in Icon" book, you
  89. should get it as an invaluable reference.
  90.  
  91.  
  92.  
  93. > _________________________________________________________________
  94. > Choose an Internet access plan right for you -- try MSN!
  95. > http://resourcecenter.msn.com/access/plans/default.asp
  96.  
  97. -- 
  98. Steve Wampler -- swampler@noao.edu
  99. Quantum materiae materietur marmota monax si marmota
  100.                     monax materiam possit materiari?
  101.